package com.moneyanalyzer;

import com.moneyanalyzer.dao.CategoryDao;
import com.moneyanalyzer.model.Category;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;

public class CategoryAdd extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_category_add);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.category_add, menu);
		return true;
	}
	
	public void addNewCategoria(View view){
		CategoryDao dao = CategoryDao.getInstance();
		EditText editText = (EditText) findViewById(R.id.new_category);
		String nameCategory = editText.getText().toString();
		Category category = new Category();
		category.setName(nameCategory);
		dao.insert(category, getApplicationContext());
		Intent intent = new Intent(this, ListCategory.class);
    	startActivity(intent);
	}

}
